package test7;

public class Demo9 {
    public static void main(String[] args) {
        String s = "a";
        int i = lengthOfLongestSubstring(s);
        System.out.println(i);
    }

    public static int lengthOfLongestSubstring(String s) {
        int l = 0, r = 1, max = 1;
        while (r < s.length()) {
            char c = s.charAt(r);
            for (int i = l; i < r; i ++) {
                if (c == s.charAt(i)) {
                    l = i + 1;
                    break;
                }
            }
            int len = r - l + 1;
            if (len > max) max = len;
            r ++;
        }
        return max;
    }
}
